package task1;

import java.util.List;

public class StudentMod {
    public static void modify(List<Student> students, String id, String name, int age){
        for(int i = 0; i < students.size(); i++){
            if(students.get(i).getId().equals(id)){
                Student student = students.get(i);
                student.setName(name);
                try {
                    student.setAge(age);
                } catch (StudentAgeException e) {
                    e.printStackTrace();
                }
                students.set(i, student);
                System.out.println("已修改学生信息：" + student);
                return;
            }
        }
        System.out.println("未找到该ID学生，修改失败");
    }
}
